import mynavbar from '@/components/mynavbar'
export default function (Vue) {
  Vue.component('mynavbar', mynavbar)
  // 注册全局自定义执行v-image
  Vue.directive('image', {
    inserted: function (el, binding) {
      // console.log(111)
      // console.log(binding.value)
      // console.dir(el)
      // el.onload = function () {
      //   console.log(111)
      //   console.log(binding.value)
      //   el.src = binding.value
      // }
      // // 在图片加载失败的时候执行onerror方法 给src赋值
      // el.onerror = function () {
      //   console.log(2222)
      //   el.src = 'http://via.placeholder.com/600x400.png'
      // }
      el.src = el.src || binding.value
      el.onerror = function () {
        console.log(111)
        el.src = binding.value
      }
    },
    componentUpdated (el, binding) {
      el.src = el.src || binding.value
    }
  })
}
